package com.bzkj.web.controller.basic;

import com.bzkj.basicinfo.domain.basic.BasicSkuInfo;
import com.bzkj.basicinfo.service.basic.BasicSkuInfoService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：swj
 * @Desc wms商品信息
 * @Date：2025/9/28 14:46
 */
@Api(tags = "商品信息")
@RestController
@RequestMapping("/basic/skuInfo")
public class BasicSkuInfoController extends BaseController {
    @Autowired
    private BasicSkuInfoService basicSkuInfoService;

    @ApiOperation("查询接口")
    @GetMapping("/queryList")
    public TableDataInfo findBasicSkuInfoDataPage(BasicSkuInfo skuInfo) {
        startPage();
        return getDataTable(basicSkuInfoService.queryAllList(skuInfo));
    }

    @ApiOperation("新增接口")
    @LogC(title = "商品信息",businessType = BusinessType.INSERT,tableNames = "basic_sku_info",
            pkFieldNames = "id",content = "'商品名称：'+#skuInfo.productName")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BasicSkuInfo skuInfo) {
        return AjaxResult.success(basicSkuInfoService.add(skuInfo));
    }

    @ApiOperation("修改接口")
    @LogC(title = "商品信息",businessType = BusinessType.UPDATE,tableNames = "basic_sku_info",
            pkFieldNames = "id",content = "'商品名称：'+#skuInfo.productName")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody BasicSkuInfo skuInfo) {
        return AjaxResult.success(basicSkuInfoService.update(skuInfo));
    }

    @ApiOperation("修改状态接口")
//    @LogC(title = "商品信息",businessType = BusinessType.UPDATE)
    @PostMapping("/updateState")
    public AjaxResult updateState(@RequestParam String id,@RequestParam String state) {
        return AjaxResult.success(basicSkuInfoService.updateState(id,state));
    }

    @ApiOperation("删除接口")
    @LogC(title = "商品信息",businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(@RequestParam String id) {
        return AjaxResult.success(basicSkuInfoService.delete(id));
    }

}
